#######################################################################################################
### 14/10/2020 - Written by Cyril Pineiro / SYNAPSYS-IT
### Check if Network Interface is Vulnerable to CVE-2020-16898 & CVE-2020-16899
### Returns Interface Index and Alias
#######################################################################################################

Clear

$interfaces = (Get-NetIPInterface | where {$_.AddressFamily -eq "IPv6"}).ifIndex
foreach ($interface in $interfaces)
{
    [bool]$vuln = $false
    $output = netsh int ipv6 sh interfaces interface=$interface
    foreach ($Line in $output)
    {
        if($Line.Contains("6106") -and $Line.Contains("enabled"))
        {
            [bool]$vuln = $true
        }
    }
    $NetIPInterfaceAlias = ((Get-NetIPAddress -InterfaceIndex $interface | Select-Object InterfaceAlias)[0]).InterfaceAlias
    if ($vuln)
    {
        Write-Host "Interface '$($interface)' named '$($NetIPInterfaceAlias)' is Vulnerable to CVE-2020-16898 & CVE-2020-16899" -ForegroundColor Red
    }
    else
    {
        Write-Host "Interface '$($interface)' named '$($NetIPInterfaceAlias)' is Not Vulnerable to CVE-2020-16898 & CVE-2020-16899" -ForegroundColor Green
    }
}
